<?php
//生成时间2022-08-15 09:17
class ehr{
    static private $s_no=NULL;//工号
    static public function Set_s_no($s_no){
        if(strlen($s_no)<1 || strlen($s_no)>20){
            return 101;
        }
        if(!preg_match("/^([A-Z]|[a-z]|\d)(\d{4,17}|(\d{4,17}[A-Z]\d{0,4}))|(^\d{18}$)|(^\d{17}(\d|X|x)$)$/",$s_no)){
            return 103;
        }
        self::$s_no=$s_no;
        return 1;
    }
    static private $s_name=NULL;//姓名
    static public function Set_s_name($s_name){
        if(strlen($s_name)<0 || strlen($s_name)>90){
            return 101;
        }
        self::$s_name=$s_name;
        return 1;
    }
    static private $s_dept=NULL;//部门
    static public function Set_s_dept($s_dept){
        if(strlen($s_dept)<1 || strlen($s_dept)>300){
            return 101;
        }
        self::$s_dept=$s_dept;
        return 1;
    }
    static private $s_sex=NULL;//性别
    static public function Set_s_sex($s_sex){
        if(strlen($s_sex)<1 || strlen($s_sex)>20){
            return 101;
        }
        if(!in_array($s_sex,array("男","女"))){
            return 102;
        }
        self::$s_sex=$s_sex;
        return 1;
    }
    static private $s_ingroup_date=NULL;//入集团日期
    static public function Set_s_ingroup_date($s_ingroup_date){
        if(strlen($s_ingroup_date)<1 || strlen($s_ingroup_date)>20){
            return 101;
        }
        if(!preg_match("/(^\d{4}\/([1-9]|1[1-2])\/([1-9]|[1-2][0-9]|3[0-1])$)|(^\d{4}\-(0[1-9]|1[0-2])\-(0[1-9]|[1-2][0-9]|3[0-1])$)/",$s_ingroup_date)){
            return 103;
        }
        self::$s_ingroup_date=$s_ingroup_date;
        return 1;
    }
    static private $s_tel=NULL;//手机号码
    static public function Set_s_tel($s_tel){
        if(strlen($s_tel)<1 || strlen($s_tel)>20){
            return 101;
        }
        if(!preg_match("/\d{3}-\d{8}|\d{4}-\d{7}/",$s_tel)){
            return 103;
        }
        self::$s_tel=$s_tel;
        return 1;
    }
    static private $s_position=NULL;//职位
    static public function Set_s_position($s_position){
        if(strlen($s_position)<1 || strlen($s_position)>90){
            return 101;
        }
        self::$s_position=$s_position;
        return 1;
    }
    static private $s_level=NULL;//资位
    static public function Set_s_level($s_level){
        if(strlen($s_level)<1 || strlen($s_level)>90){
            return 101;
        }
        if(!in_array($s_level,array("员1","员2","员3","师1","师2","师3","师4","师5","师6","师7","师8","师9","师10","师11","师11","师12","师13","师14","师15","师16","师17","师18","师19","师20"))){
            return 102;
        }
        self::$s_level=$s_level;
        return 1;
    }
    static private $s_married=NULL;//婚姻状况
    static public function Set_s_married($s_married){
        if(strlen($s_married)<1 || strlen($s_married)>20){
            return 101;
        }
        if(!in_array($s_married,array("未婚","已婚"))){
            return 102;
        }
        self::$s_married=$s_married;
        return 1;
    }
    static private $s_city=NULL;//籍贯
    static public function Set_s_city($s_city){
        if(strlen($s_city)<1 || strlen($s_city)>90){
            return 101;
        }
        self::$s_city=$s_city;
        return 1;
    }
    static private $s_company=NULL;//法人
    static public function Set_s_company($s_company){
        if(strlen($s_company)<1 || strlen($s_company)>300){
            return 101;
        }
        self::$s_company=$s_company;
        return 1;
    }
    static public function Add(){
        $sql="insert into g2_ehr_t(";
        $sql.=self::$s_no!=NULL?"s_no,":'';
        $sql.=self::$s_name!=NULL?"s_name,":'';
        $sql.=self::$s_dept!=NULL?"s_dept,":'';
        $sql.=self::$s_sex!=NULL?"s_sex,":'';
        $sql.=self::$s_ingroup_date!=NULL?"s_ingroup_date,":'';
        $sql.=self::$s_tel!=NULL?"s_tel,":'';
        $sql.=self::$s_position!=NULL?"s_position,":'';
        $sql.=self::$s_level!=NULL?"s_level,":'';
        $sql.=self::$s_married!=NULL?"s_married,":'';
        $sql.=self::$s_city!=NULL?"s_city,":'';
        $sql.=self::$s_company!=NULL?"s_company,":'';
        $sql=trim($sql,',');
        $sql.=") values (";
        $sql.=self::$s_no!=NULL?"'".self::$s_no."',":'';
        $sql.=self::$s_name!=NULL?"'".self::$s_name."',":'';
        $sql.=self::$s_dept!=NULL?"'".self::$s_dept."',":'';
        $sql.=self::$s_sex!=NULL?"'".self::$s_sex."',":'';
        $sql.=self::$s_ingroup_date!=NULL?"'".self::$s_ingroup_date."',":'';
        $sql.=self::$s_tel!=NULL?"'".self::$s_tel."',":'';
        $sql.=self::$s_position!=NULL?"'".self::$s_position."',":'';
        $sql.=self::$s_level!=NULL?"'".self::$s_level."',":'';
        $sql.=self::$s_married!=NULL?"'".self::$s_married."',":'';
        $sql.=self::$s_city!=NULL?"'".self::$s_city."',":'';
        $sql.=self::$s_company!=NULL?"'".self::$s_company."',":'';
        $sql=trim($sql,',');
        $sql.=");";
        return $sql;
    }
    static public function Edit(){
        $sql="update g2_ehr_t set ";
        $sql.=self::$s_name!=NULL?"s_name='".self::$s_name."',":'';
        $sql.=self::$s_dept!=NULL?"s_dept='".self::$s_dept."',":'';
        $sql.=self::$s_sex!=NULL?"s_sex='".self::$s_sex."',":'';
        $sql.=self::$s_ingroup_date!=NULL?"s_ingroup_date='".self::$s_ingroup_date."',":'';
        $sql.=self::$s_tel!=NULL?"s_tel='".self::$s_tel."',":'';
        $sql.=self::$s_position!=NULL?"s_position='".self::$s_position."',":'';
        $sql.=self::$s_level!=NULL?"s_level='".self::$s_level."',":'';
        $sql.=self::$s_married!=NULL?"s_married='".self::$s_married."',":'';
        $sql.=self::$s_city!=NULL?"s_city='".self::$s_city."',":'';
        $sql.=self::$s_company!=NULL?"s_company='".self::$s_company."',":'';
        $sql=trim($sql,',');
        $sql.=" where 1=1";
        $sql.=self::$s_no!=NULL?" and s_no='".self::$s_no."'":'';
        return $sql.';';
    }
    static public function Delete(){
        $sql="delete from g2_ehr_t";
        $sql.=" where 1=1";
        $sql.=self::$s_no!=NULL?" and s_no='".self::$s_no."'":'';
        return $sql.';';
    }
    static public function Select(){
        $sql="select * from g2_ehr_t";
        return $sql;
    }
}
?>